Skip to content

Conversation

@waaake
Copy link
Contributor

@waaake waaake commented Nov 25, 2024

Description

Added Color Selector in the Graph Editor

Features list

  • The Color Selector Provides a really quick way to apply color onto selected nodes or to remove it.
  • Currently holds a limited set of frequently used colors.
  • Uses 'C' Key as the shortcut to toggle the Color Selector.

Implementation remarks

The color selector in the Graph Editor provides a quick way to color nodes with predefined palette of colors.

Added Command to allow the Coloring to be undone and redone using QUndoStack
@waaake waaake self-assigned this Nov 25, 2024
Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation-wise: this should rely on the existing SetAttributeCommand.
UX-wise: I would suggest re-working the color palette for better contrast with the font color.

self.selectNodes(self._graph.dfsOnDiscover(startNodes=[node], reverse=True, dependenciesOnly=True)[0])

@Slot(str)
def updateNodeColor(self, color):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this method is working on the node selection (which makes sense), I would recommend:

Suggested change
def updateNodeColor(self, color):
def setSelectedNodesColor(self, color: str):

Current meshroom nodes have the FG text in gray and the background color needs to constrast well else the text becomes unreadable
Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor fixes left, but LGTM after that 👍.

return self.internalAttribute("color").value.strip()
return ""

def setColor(self, color: str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With regards to what this PR is addressing, adding the setter for this property is not needed.

internalAttributesChanged = Signal()
label = Property(str, getLabel, notify=internalAttributesChanged)
color = Property(str, getColor, notify=internalAttributesChanged)
color = Property(str, getColor, setColor, notify=internalAttributesChanged)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same as above) Adding the setter is not needed in this scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been removed.

color (str): Hex code of the color to be set on the nodes.
"""
# Update the color attribute of the nodes which are currently selected
with self.groupedGraphModification("Update Color for Select Nodes"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the command name that appears in the undo stack:

Suggested change
with self.groupedGraphModification("Update Color for Select Nodes"):
with self.groupedGraphModification("Set Nodes Color"):

I think we could go with removing the notion of "selected" in those, as selection operations are not undoable - therefore, undoing "Set Selected Nodes Color" is a bit ambiguous if the selection has changed in between.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense, I probably did not notice this while working on the previous comments. Thanks for the suggestion.

Coloring the nodes now uses setAttribute command instead of relying on refrences to Nodes within the graph.
Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "C" shortcut is currently breaking the Copy action (Ctrl+C).

Keys.onPressed: function(event) {
if (event.key === Qt.Key_F) {
fit()
} else if (event.key === Qt.Key_C) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes precedence over the copy shortcut (Ctrl+C).
We need better handling of keyboard shortcuts, but in the meantime, this should either test if no modifier are active, or be moved at after the copy action handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's my bad, I did not notice something as simple as this. Have updated the code to consider both cases.

Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@yann-lty yann-lty merged commit e800cd4 into develop Nov 29, 2024
3 checks passed
@yann-lty yann-lty deleted the dev/NodeColoring branch November 29, 2024 10:16
@fabiencastan fabiencastan added this to the Meshroom 2025.1.0 milestone Aug 1, 2025
@fabiencastan fabiencastan added the feature new feature (proposed as PR or issue planned by dev) label Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature new feature (proposed as PR or issue planned by dev)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants